package com.enen.service.impl;

import com.enen.mapper.DeptMapper;
import com.enen.pojo.Dept;
import com.enen.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
//查询所有部门信息
@Service //业务处理层，在这里写业务逻辑的代码
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper; //依赖注入，调用mapper里的增删改查
    @Override
    public List<Dept> findAll() {
        return deptMapper.findAll();
    }

    @Override
    public void delect(Integer id) {
        deptMapper.delect(id);
    }

    @Override
    public void add(Dept dept) {
        //创建时间
        dept.setCreateTime(LocalDateTime.now());
        //修改时间
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.add(dept);
    }

    @Override
    public Dept findId(Integer id) {
        return deptMapper.findId(id);
    }

    @Override
    public void update(Dept dept) {
        //修改时间
        dept.setUpdateTime(LocalDateTime.now());

        deptMapper.update(dept);
    }

}
